// pages/order/myOrder/myOrder.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isEmpty:1,
    orderList:[
      { storeName: '义泰昌（车公庙店）', storeImg: '../../../libs/images/b_n.png', orderTime: '2018-04-02 15:36:25', orderDish: ['米饭', '鱼香肉丝', '特制龙骨汤'], orderDishLength: 3, orderPrice: 35.5, orderState: 0, stateList: ['待支付', '待接单', '商家已接单', '配送中', '订单已完成', '已取消', '已退单', '商家已拒单', '退款申请中',]},
      { storeName: '义泰昌（南山蛇口店）', storeImg: '../../../libs/images/b_n.png', orderTime: '2018-01-21 15:36:25', orderDish: ['米饭', '鱼香肉丝', '特制龙骨汤'], orderDishLength: 3, orderPrice: 35.5, orderState: 1, stateList: ['待支付', '待接单', '商家已接单', '配送中', '订单已完成', '已取消', '已退单', '商家已拒单', '退款申请中',] },
      { storeName: '义泰昌（宝安水立方店）', storeImg: '../../../libs/images/b_n.png', orderTime: '2018-04-02 15:36:25', orderDish: ['米饭', '鱼香肉丝', '特制龙骨汤'], orderDishLength: 3, orderPrice: 35.5, orderState: 2, stateList: ['待支付', '待接单', '商家已接单', '配送中', '订单已完成', '已取消', '已退单', '商家已拒单', '退款申请中',]},
      { storeName: '义泰昌（宝安水立方店）', storeImg: '../../../libs/images/b_n.png', orderTime: '2018-04-02 15:36:25', orderDish: ['米饭', '鱼香肉丝', '特制龙骨汤'], orderDishLength: 3, orderPrice: 35.5, orderState: 3, stateList: ['待支付', '待接单', '商家已接单', '配送中', '订单已完成', '已取消', '已退单', '商家已拒单', '退款申请中',] },
      { storeName: '义泰昌（宝安水立方店）', storeImg: '../../../libs/images/b_n.png', orderTime: '2018-04-02 15:36:25', orderDish: ['米饭', '鱼香肉丝', '特制龙骨汤'], orderDishLength: 3, orderPrice: 35.5, orderState: 8, stateList: ['待支付', '待接单', '商家已接单', '配送中', '订单已完成', '已取消', '已退单', '商家已拒单', '退款申请中',] },
      { storeName: '义泰昌（宝安水立方店）', storeImg: '../../../libs/images/b_n.png', orderTime: '2018-04-02 15:36:25', orderDish: ['米饭', '鱼香肉丝', '特制龙骨汤'], orderDishLength: 3, orderPrice: 35.5, orderState: 5, stateList: ['待支付', '待接单', '商家已接单', '配送中', '订单已完成', '已取消', '已退单', '商家已拒单', '退款申请中',] },
      { storeName: '义泰昌（宝安水立方店）', storeImg: '../../../libs/images/b_n.png', orderTime: '2018-04-02 15:36:25', orderDish: ['米饭', '鱼香肉丝', '特制龙骨汤'], orderDishLength: 3, orderPrice: 35.5, orderState: 6, stateList: ['待支付', '待接单', '商家已接单', '配送中', '订单已完成', '已取消', '已退单', '商家已拒单', '退款申请中',] },
      { storeName: '义泰昌（宝安水立方店）', storeImg: '../../../libs/images/b_n.png', orderTime: '2018-04-02 15:36:25', orderDish: ['米饭', '鱼香肉丝', '特制龙骨汤'], orderDishLength: 3, orderPrice: 35.5, orderState: 7, stateList: ['待支付', '待接单', '商家已接单', '配送中', '订单已完成', '已取消', '已退单', '商家已拒单', '退款申请中',] },
      { storeName: '义泰昌（宝安水立方店）', storeImg: '../../../libs/images/b_n.png', orderTime: '2018-04-02 15:36:25', orderDish: ['米饭', '鱼香肉丝', '特制龙骨汤'], orderDishLength: 3, orderPrice: 35.5, orderState: 4, stateList: ['待支付', '待接单', '商家已接单', '配送中', '订单已完成', '已取消', '已退单', '商家已拒单', '退款申请中',] }
    ],
    chargebackTxt:'骑手已开始配送'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var orderList = this.data.orderList;
    if (orderList == '' || orderList == null){
      this.setData({
        isEmpty:0
      })
    }
  
  },
  // 取消订单按钮
  orderCancel:function(){
    wx.showModal({
      title: '是否确认取消该订单',
      content: '',
      success: function (res) {
        if (res.confirm) {
          wx.showToast({
            title: '订单取消成功',
            icon: 'none',
            duration: 2000
          })
        } else if (res.cancel) {
          
        }
      }
    })
  },
  // 申请退单按钮
  chargeback:function(){
    var that = this;
    wx.showModal({
      title: '商家已接单，是否确认申请退单',
      content: '',
      success: function (res) {
        if (res.confirm) {
          wx.showModal({
            title: '商家拒绝退单',
            content: '理由：' + that.data.chargebackTxt,
            success: function (res) {
              if (res.confirm) {
                
              } else if (res.cancel) {

              }
            }
          })
        } else if (res.cancel) {
          
        }
      }
    })
  },
  // 点击打开订单详情
  toOrderDetail:function(){
    wx.navigateTo({
      url: '../orderDetail/orderDetail',
    })
  },
  // 再来一单
  orderAgain:function(e){

  },
  // 前往支付
  gotoPay:function(){

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})